using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UIElements;

public class ShelfInfo : MonoBehaviour
{
    public GameObject goodInfo;
    private Transform playerTransform;
    private TMP_Text text;
    // Start is called before the first frame update
    void Start()
    {
        playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
        text = goodInfo.GetComponent<TMP_Text>();
        var cost = GetComponentInParent<Shelf>().Cost;
        text.text = cost.costItem + ": " + cost.costAmount;
    }

    // Update is called once per frame
    void Update()
    {
        var length = (playerTransform.position - transform.position).magnitude;
        if (length < 2)
        {
            goodInfo.SetActive(true);
            return;
        }
        goodInfo.SetActive(false);
    }
}
